(function ($){ if(!$) return; var ua=navigator.userAgent, isIE=ua.match(/msie/i), isIE6=isIE&&ua.match(/msie 6\./i), location=window.location, isHttpsScheme=location&&location.protocol&&location.protocol=='https:'; $.extend({ amazonjs:{ imageAttributes: ['SmallImage', 'MediumImage', 'LargeImage'], isCustomerReviewEnabled: false, isTrackEventEnabled: false, resource: {}, initTemplate:function (){ var r=this.resource; var linkOpenTag=''; var smallImageTemplate = [ '{{if SmallImage}}', '{{if $item.setInfoMargin(SmallImage.width+10)}}{{/if}}', '
', linkOpenTag, '${Title}', '', '
', '{{/if}}' ].join(''); var mediumImageTemplate = [ '{{if MediumImage}}', '{{if $item.setInfoMargin(MediumImage.width+10)}}{{/if}}', '
', linkOpenTag, '${Title}', '', '
', '{{/if}}' ].join(''); var largeImageTemplate = [ '{{if LargeImage}}', '{{if $item.setInfoMargin(LargeImage.width+10)}}{{/if}}', '
', linkOpenTag, '${Title}', '', '
', '{{/if}}' ].join(''); var imageTemplate = [ '{{if _ShowSmallImage}}',smallImageTemplate,'{{/if}}', '{{if _ShowMediumImage}}',mediumImageTemplate,'{{/if}}', '{{if _ShowLargeImage}}',largeImageTemplate,'{{/if}}' ].join(''); var linkTemplate=linkOpenTag + '${Title}'; var priceContentTemplate = [ '{{if $item.isSale()}}', '' + r.ListPrice + '${ListPrice.FormattedPrice}
', '{{if OfferSummary.LowestNewPrice}}' + r.Price + '${OfferSummary.LowestNewPrice.FormattedPrice}{{/if}}', '' + r.PriceUpdatedat + '', '{{else}}', '' + r.Price + '${ListPrice.FormattedPrice}', '' + r.PriceUpdatedat + '', '{{/if}}' ].join(''); var priceTemplate='{{if ListPrice}}
' + priceContentTemplate + '
{{/if}}'; var priceLiTemplate='{{if ListPrice}}
  • ' + priceContentTemplate + '
  • {{/if}}'; var reviewLinkTemplate=''; if(this.isCustomerReviewEnabled){ reviewLinkTemplate='' + r.SeeCustomerReviews + ''; } this.partial={ smallImage:smallImageTemplate, mediumImage:mediumImageTemplate, largeImage:largeImageTemplate, link:linkTemplate, price:priceTemplate }; var defaultTemplates={ Small:[ '
    ', imageTemplate, '{{if _ShowDefaultImage}}',smallImageTemplate,'{{/if}}', '
    ', '

    ',linkTemplate,'

    ', '', '
    ', reviewLinkTemplate, '', '
    ' ], Music:[ '
    ', imageTemplate, '{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}', '
    ', '

    ',linkTemplate,'

    ', '', '
    ', reviewLinkTemplate, '', '
    ' ], DVD:[ '
    ', imageTemplate, '{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}', '
    ', '

    ',linkTemplate,'

    ', '', '
    ', reviewLinkTemplate, '', '
    ' ], Book:[ '
    ', imageTemplate, '{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}', '
    ', '

    ',linkTemplate,'

    ', '', '
    ', reviewLinkTemplate, '', '
    ' ], eBooks:[ '
    ', imageTemplate, '{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}', '
    ', '

    ',linkTemplate,'

    ', '', '
    ', reviewLinkTemplate, '', '
    ' ] }; this.template(defaultTemplates); var me=this; $.each(this.addTemplateCallbacks, function (i, callback){ var t=callback.call(me, me.partial); if(t) me.template(t); }); }, addTemplateCallbacks:[], addTemplate:function (fn){ if(typeof(fn)=='function'){ this.addTemplateCallbacks.push(fn); }}, template:function (templates){ $.each(templates, function (name, tmpl){ if(tmpl){ $.template('amazonjs' + name + 'Tpl', (typeof tmpl==='string') ? tmpl:tmpl.join('')); }}); }, render:function (items){ var $items=[]; this.initTemplate(); $(".amazonjs_item").each(function (){ var classNames=$(this).attr('class').split(' '), c=classNames[0].split('_'), asin=c[1], countryCode=c[2], tmpl=(c.length > 3) ? c[3]:null, item=find(asin, countryCode), imgSize=$(this).attr('data-img-size') ; if(item){ item._ImageSize=imgSize||''; var $item=$.amazonjs.tmpl(item, $.amazonjs.formatTmplName(tmpl)); $(this).replaceWith($item.hide()); var $review=$item.find('.amazonjs_review'); if(isIE6){ $item.css('position', 'static'); $review.css({ 'float':'right', 'position':'static', 'marginRight':'32px' }); } $review.click(function (){ tb_show(this.title, this.href); this.blur(); return false; }); if($.amazonjs.isTrackEventEnabled){ $item.find('.amazonjs_link').click(function(){ try { var data=$(this).data(); var title=$(this).attr('title'); if(data.role=='amazonjs_product'){ if($.isFunction(ga)){ ga('send', 'event', 'AmazonJS', 'Click', data.asin + ' ' + title); }else if(_gaq){ _gaq.push(['_trackEvent', 'AmazonJS', 'Click', data.asin + ' ' + title]); }} } catch (e){ }}); } $items.push($item); }else{ tmpl='Link' + countryCode.toUpperCase(); item={ asins:asin, fc1:'000000', lc1:'0000FF', bc1:'000000', bg1:'FFFFFF', IS2:1, lt1:'_blank', f:'ifr', m:'amazon' }; var $item=$.amazonjs.tmpl(item, $.amazonjs.formatTmplName(tmpl)); $(this).replaceWith($item); }}); function find(asin, countryCode){ for (var i=0, length=items.length; i < length; i++){ if(items[i].ASIN==asin&&items[i].CountryCode==countryCode){ return items[i]; }} } if($.amazonjs.isFadeInEnabled){ function fadeIn(){ if($items.length > 0){ var $item=$items.shift(); $item.fadeIn(); setTimeout(fadeIn, 100); }} fadeIn(); }else{ $.each($items, function(){ this.show(); }); }}, formatTmplName:function (key){ return (key) ? 'amazonjs' + key + 'Tpl':null; }, formatNumber:function (val){ val +=''; var x=val.split('.'), x1=x[0], x2=x.length > 1 ? '.' + x[1]:'', rgx=/(\d+)(\d{3})/; while (rgx.test(x1)){ x1=x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; }, formatDateTime:function (timestamp){ var dt=new Date(timestamp * 1000); var Y=dt.getFullYear(), m=dt.getMonth() + 1, d=dt.getDate(), H=dt.getHours(), i=dt.getMinutes(); if(m < 10) m='0' + m; if(d < 10) d='0' + d; if(H < 10) H='0' + H; if(i < 10) i='0' + i; return Y + '/' + m + '/' + d + ' ' + H + ':' + i; }, getTemplate:function (item){ var defaultTmpl=this.formatTmplName('Small'); if(item&&item.ProductGroup){ var tmpl=this.formatTmplName(item.ProductGroup); return $.template[tmpl]||defaultTmpl; } return defaultTmpl; }, prepareData:function (item){ if(isHttpsScheme){ $.each(this.imageAttributes, function(i, v){ var image=item[v]; if(image&&image.src){ image.src=image.src.replace('http://ecx.images-amazon.com', 'https://images-eu.ssl-images-amazon.com'); }}); } item._ShowDefaultImage=_ShowSmallImage=item._ShowMediumImage=item._ShowLargeImage=false; if(item._ImageSize=='small') item._ShowSmallImage=true; else if(item._ImageSize=='medium') item._ShowMediumImage=true; else if(item._ImageSize=='large') item._ShowLargeImage=true; else item._ShowDefaultImage=true; item.PublicationDate=item.PublicationDate||item.ReleaseDate; item.Manufacturer=item.Manufacturer||item.Label; if(item.SalesRank) item.SalesRank=this.formatNumber(item.SalesRank); if(item.PublicationDate) item.PublicationDate=item.PublicationDate.replace(/-/g, '/'); if(item.ReleaseDate) item.ReleaseDate=item.ReleaseDate.replace(/-/g, '/'); if(item.Artist&&item.Creator){ var Creator=[]; var a=$.isArray(item.Artist) ? item.Artist:[item.Artist]; var c=$.isArray(item.Creator) ? item.Creator:[item.Creator]; $.each(c, function (i, value){ if($.inArray(value, a)==-1) Creator.push(value); }); item.Creator=(Creator.length) ? Creator:null; } item.UpdatedDate=this.formatDateTime(item.UpdatedAt); return item; }, tmpl:function (item, tmpl){ item=this.prepareData(item); if(!item.ListPrice&&item.OfferSummary){ item.ListPrice=item.OfferSummary.LowestNewPrice; } return $.tmpl($.template[tmpl]||this.getTemplate(item), item, { isSale:function (){ if(this.data){ var lp=this.data.ListPrice, la=Number(lp.Amount), os=this.data.OfferSummary||{}, sp=os.LowestNewPrice||{}, sa=Number(sp.Amount); return (!isNaN(sa)&&sa < la); } return false; }, setInfoMargin: function(margin){ return this.data._InfoMarginLeft=margin; }}); }, execute: function(){ var amazonjsVars=window.amazonjsVars; if(amazonjsVars){ function render(){ if(!amazonjsVars.items){ return; } if($.amazonjs.isRendered){ return; } if(amazonjsVars.isCustomerReviewEnabled){ if(typeof tb_pathToImage==='undefined'){ tb_pathToImage=amazonjsVars.thickboxUrl + '/loadingAnimation.gif'; } if(typeof tb_closeImage==='undefined'){ tb_closeImage=amazonjsVars.thickboxUrl + '/tb-close.png'; }} $.amazonjs.isFadeInEnabled=amazonjsVars.isFadeInEnabled; $.amazonjs.isCustomerReviewEnabled=amazonjsVars.isCustomerReviewEnabled; $.amazonjs.isTrackEventEnabled=amazonjsVars.isTrackEventEnabled; $.amazonjs.resource=amazonjsVars.resource; $.amazonjs.template(amazonjsVars.regionTemplate); $.amazonjs.render(amazonjsVars.items); $.amazonjs.isRendered=true; } if(amazonjsVars.isFadeInEnabled){ setTimeout(function (){ render(); }, 1000); }else{ render(); }} }} }); var boot=function(){ $.amazonjs.execute(); }; $(document).ready(boot); if($.fn.on){ $(window).on('load', boot); }else if($.fn.load){ $(window).load(boot); } if(document.addEventListener){ document.addEventListener('DOMContentLoaded', boot); }})(jQuery); jQuery(document).ready(function($){ $('body:not(.su-other-shortcodes-loaded)').on('click keypress', '.su-spoiler-title', function(e){ var $title=$(this), $spoiler=$title.parent(), bar=($('#wpadminbar').length > 0) ? 28:0; $spoiler.toggleClass('su-spoiler-closed'); $spoiler.parent('.su-accordion').children('.su-spoiler').not($spoiler).addClass('su-spoiler-closed'); if($(window).scrollTop() > $title.offset().top) $(window).scrollTop($title.offset().top - $title.height() - bar); e.preventDefault(); }); $('body:not(.su-other-shortcodes-loaded)').on('click keypress', '.su-tabs-nav span', function(e){ var $tab=$(this), data=$tab.data(), index=$tab.index(), is_disabled=$tab.hasClass('su-tabs-disabled'), $tabs=$tab.parent('.su-tabs-nav').children('span'), $panes=$tab.parents('.su-tabs').find('.su-tabs-pane'), $gmaps=$panes.eq(index).find('.su-gmap:not(.su-gmap-reloaded)'); if(is_disabled) return false; $panes.removeClass('su-tabs-pane-open').eq(index).addClass('su-tabs-pane-open'); $tabs.removeClass('su-tabs-current').eq(index).addClass('su-tabs-current'); if($gmaps.length > 0) $gmaps.each(function(){ var $iframe=$(this).find('iframe:first'); $(this).addClass('su-gmap-reloaded'); $iframe.attr('src', $iframe.attr('src')); }); tabs_height(); if(data.url!==''){ if(data.target==='self') window.location=data.url; else if(data.target==='blank') window.open(data.url); } e.preventDefault(); }); $('.su-tabs').each(function(){ var active=parseInt($(this).data('active')) - 1; $(this).children('.su-tabs-nav').children('span').eq(active).trigger('click'); tabs_height(); }); anchor_nav(); $(document).on('click', '.su-lightbox', function(e){ e.preventDefault(); e.stopPropagation(); if($(this).parent().attr('id')==='su-generator-preview') $(this).html(su_other_shortcodes.no_preview); else { var type=$(this).data('mfp-type'); $(this).magnificPopup({ type: type, tClose: su_magnific_popup.close, tLoading: su_magnific_popup.loading, gallery: { tPrev: su_magnific_popup.prev, tNext: su_magnific_popup.next, tCounter: su_magnific_popup.counter }, image: { tError: su_magnific_popup.error }, ajax: { tError: su_magnific_popup.error }}).magnificPopup('open'); }}); $('.su-frame-align-center, .su-frame-align-none').each(function(){ var frame_width=$(this).find('img').width(); $(this).css('width', frame_width + 12); }); $('.su-tooltip').each(function(){ var $tt=$(this), $content=$tt.find('.su-tooltip-content'), is_advanced=$content.length > 0, data=$tt.data(), config={ style: { classes: data.classes }, position: { my: data.my, at: data.at, viewport: $(window) }, content: { title: '', text: '' }}; if(data.title!=='') config.content.title=data.title; if(is_advanced) config.content.text=$content; else config.content.text=$tt.attr('title'); if(data.close==='yes') config.content.button=true; if(data.behavior==='click'){ config.show='click'; config.hide='click'; $tt.on('click', function(e){ e.preventDefault(); e.stopPropagation(); }); $(window).on('scroll resize', function(){ $tt.qtip('reposition'); }); }else if(data.behavior==='always'){ config.show=true; config.hide=false; $(window).on('scroll resize', function(){ $tt.qtip('reposition'); }); }else if(data.behavior==='hover'&&is_advanced){ config.hide={ fixed: true, delay: 600 };} $tt.qtip(config); }); $('body:not(.su-other-shortcodes-loaded)').on('click', '.su-expand-link', function(){ var $this=$(this), $container=$this.parents('.su-expand'), $content=$container.children('.su-expand-content'); if($container.hasClass('su-expand-collapsed')){ $content.css('max-height', 'none'); }else{ $content.css('max-height', $container.data('height') + 'px'); } $container.toggleClass('su-expand-collapsed'); }); function is_transition_supported(){ var thisBody=document.body||document.documentElement, thisStyle=thisBody.style, support=thisStyle.transition!==undefined||thisStyle.WebkitTransition!==undefined||thisStyle.MozTransition!==undefined||thisStyle.MsTransition!==undefined||thisStyle.OTransition!==undefined; return support; } if(is_transition_supported()){ $('.su-animate').each(function(){ $(this).one('inview', function(e){ var $this=$(this), data=$this.data(); window.setTimeout(function(){ $this.addClass(data.animation); $this.addClass('animated'); $this.css('visibility', 'visible'); }, data.delay * 1000); }); }); }else{ $('.su-animate').css('visibility', 'visible'); } function tabs_height(){ $('.su-tabs-vertical').each(function(){ var $tabs=$(this), $nav=$tabs.children('.su-tabs-nav'), $panes=$tabs.find('.su-tabs-pane'), height=0; $panes.css('min-height', $nav.outerHeight(true)); }); } function anchor_nav(){ if(document.location.hash==='') return; $('.su-tabs-nav span[data-anchor]').each(function(){ if('#' + $(this).data('anchor')===document.location.hash){ var $tabs=$(this).parents('.su-tabs'), bar=($('#wpadminbar').length > 0) ? 28:0; $(this).trigger('click'); window.setTimeout(function(){ $(window).scrollTop($tabs.offset().top - bar - 10); }, 100); }}); $('.su-spoiler[data-anchor]').each(function(){ if('#' + $(this).data('anchor')===document.location.hash){ var $spoiler=$(this), bar=($('#wpadminbar').length > 0) ? 28:0; if($spoiler.hasClass('su-spoiler-closed')) $spoiler.find('.su-spoiler-title:first').trigger('click'); window.setTimeout(function(){ $(window).scrollTop($spoiler.offset().top - bar - 10); }, 100); }}); } if('onhashchange' in window) $(window).on('hashchange', anchor_nav); $('body').addClass('su-other-shortcodes-loaded'); });